
from django.urls import re_path
from meiduo_admin.views.login_views import *
from meiduo_admin.views.home_views import *
from meiduo_admin.views.user_views import *
from meiduo_admin.views.sku_views import *
from meiduo_admin.views.spu_views import *
from meiduo_admin.views.spec_views import *
from meiduo_admin.views.option_views import *
from meiduo_admin.views.image_views import *
from meiduo_admin.views.order_views import *
from meiduo_admin.views.perm_views import *
from meiduo_admin.views.group_views import *
from meiduo_admin.views.admin_views import *
from rest_framework_jwt.views import obtain_jwt_token


urlpatterns = [
    # 自定义登陆视图和序列化器
    # re_path(r'^authorizations/$', LoginAPIView.as_view()),
    re_path(r'^authorizations/$', obtain_jwt_token),

    # 用户总数统计
    re_path(r'^statistical/total_count/$', UserTotalCountView.as_view()),
    # 用户日增量
    re_path(r'^statistical/day_increment/$', UserDayCountView.as_view()),
    # 日活跃用户量
    re_path(r'^statistical/day_active/$', UserActiveCountView.as_view()),
    # 日下单用户量
    re_path(r'^statistical/day_orders/$', UserOrderCountView.as_view()),
    # 月增用户量
    re_path(r'^statistical/month_increment/$', UserMonthCountView.as_view()),
    # 日分类商品访问量
    re_path(r'^statistical/goods_day_views/$', GoodsDayView.as_view()),

    # 序列化返回用户列表数据
    re_path(r'^users/$', UserAPIView.as_view()),

    # sku表管理
    re_path(r'^skus/$', SKUViewSet.as_view({
        "get": "list",
        "post": "create"
    })),
    re_path(r'^skus/(?P<pk>\d+)/$', SKUViewSet.as_view({
        "get": "retrieve",
        "put": "update",
        "delete": "destroy"
    })),

    # 新增sku可选三级分类
    re_path(r'^skus/categories/$', GoodsCateSimpleView.as_view()),
    # 新增sku可选spu数据
    re_path(r'^goods/simple/$', SPUSimpleView.as_view()),
    # 信则sku可选规格和选项信息
    re_path(r'^goods/(?P<pk>\d+)/specs/$', SpecSimpleView.as_view()),

    # spu表管理
    re_path(r'^goods/$', SPUViewSet.as_view({
        "get": "list",
        "post": "create"
    })),
    re_path(r'^goods/(?P<pk>\d+)/$', SPUViewSet.as_view({
        "get": "retrieve",
        "put": "update",
        "delete": "destroy"
    })),

    # 新增spu，可选品牌
    re_path(r'^goods/brands/simple/$', SPUViewSet.as_view({"get": "simple_brand"})),
    # 新增spu可选一级分类
    re_path(r'^goods/channel/categories/$', SPUCategorySimpleView.as_view()),
    # 新增spu可选二、三级分类
    re_path(r'^goods/channel/categories/(?P<pk>\d+)/$', SPUCategorySimpleView.as_view()),


    # 规格表管理
    re_path(r'^goods/specs/$', SpecModelViewSet.as_view({
        "get": "list",
        "post": "create"
    })),
    re_path(r'^goods/specs/(?P<pk>\d+)/$', SpecModelViewSet.as_view({
        "get": "retrieve",
        "put": "update",
        "delete": "destroy"
    })),

    # 选项表管理
    re_path(r'^specs/options/$', OptModelViewSet.as_view({
        "get": "list",
        "post": "create"
    })),
    re_path(r'^specs/options/(?P<pk>\d+)/$', OptModelViewSet.as_view({
        "get": "retrieve",
        "put": "update",
        "delete": "destroy"
    })),
    # 新增选项可选规格
    re_path(r'^goods/specs/simple/$', OptSpecSimpleView.as_view()),


    # 图片管理
    re_path(r'^skus/images/$', ImageModelViewSet.as_view({
        "get": "list",
        "post": "create"
    })),
    re_path(r'^skus/images/(?P<pk>\d+)/$', ImageModelViewSet.as_view({
        "get": "retrieve",
        "put": "update",
        "delete": "destroy"
    })),


    # 新增图片可选SKU
    re_path(r'^skus/simple/$', SKUSimpleView.as_view()),

    # 订单管理
    re_path(r'^orders/$', OrderAPIView.as_view({
        'get': 'list'
    })),
    re_path(r'^orders/(?P<pk>\d+)/$', OrderAPIView.as_view({
        'get': 'retrieve'
    })),
    re_path(r'^orders/(?P<pk>\d+)/status/$', OrderAPIView.as_view({
        'patch': 'partial_update'
    })),

    # 权限
    re_path(r'^permission/perms/$', PermModeViewSet.as_view({
        'get': 'list',
        'post': 'create'
    })),
    re_path(r'^permission/perms/(?P<pk>\d+)/$', PermModeViewSet.as_view({
        'get': 'retrieve',
        'put': 'update',
        'delete': 'destroy'
    })),
    # 新增权限可选类型
    re_path(r'^permission/content_types/$', PermContentTypeView.as_view()),

    # 分组
    re_path(r'^permission/groups/$', GroupViewSet.as_view({
        'get':'list',
        'post': 'create'
    })),
    re_path(r'^permission/groups/(?P<pk>\d+)/$', GroupViewSet.as_view({
        'get':'retrieve',
        'put' :'update',
        'delete': 'destroy'
    })),
    # 新建分组可选权限
    re_path(r'permission/simple/$', GroupPermSimpleView.as_view()),

    # 管理员管理
    re_path(r'^permission/admins/$', AdminModelViewSet.as_view({
        'get': 'list',
        'post': 'create'
    })),
    re_path(r'^permission/admins/(?P<pk>\d+)/$', AdminModelViewSet.as_view({
        'get': 'retrieve',
        'put': 'update',
        'delete': 'destroy'
    })),

    # 新增管理员可选分组
    re_path(r'permission/groups/simple/$', AdminGroupView.as_view()),
]